$(function() {
    init();

    function init() {
        eventList();
    }

    function eventList() {
        $("#loginBtn").on("click", function() {
            // console.log(111);
            /* 
            1  获取用户名
            2  获取密码
            3 验证合法性 
            */
            var username = $("#username").val().trim();
            var password = $("#password").val().trim();
            if (!username || username.length < 4) {
                alert("用户名非法!");
                return;
            }
            if (!password || password.length < 6) {
                alert("密码非法!");
                return;
            }
            // console.log("可以登录");
            var params = {
                username: username,
                password: password
            };
            // console.log(params);
            $.post(location.origin + "/employee/employeeLogin", params, function(ret) {
                if (ret.error && ret.error == 1000) {
                    alert(ret, message);
                } else if (ret.error && ret.error == 1001) {
                    alert(ret, message);
                } else {
                    alert("登录成功");
                    location.href = "./index.html";
                }
            })
        })
    }
})